package com.oxygen.pt.controller;

import com.github.pagehelper.PageInfo;
import com.oxygen.pt.pojo.dto.TreatmentRecordDTO;
import com.oxygen.pt.pojo.vo.TreatmentRecordVO;
import com.oxygen.pt.service.TreatmentRecordService;
import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

@RestController
@RequestMapping("/treatment")
@RequiredArgsConstructor
public class TreatmentRecordController {

    private final TreatmentRecordService service;

    @GetMapping("/page")
    public ResponseEntity<PageInfo<TreatmentRecordVO>> page(
            @RequestParam(required = false) Long patientId,
            @RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime startTime,
            @RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime endTime,
            @RequestParam(required = false) Integer chamberNumber,
            @RequestParam(required = false) String operator,
            @RequestParam(defaultValue = "1") int pageNum,
            @RequestParam(defaultValue = "10") int pageSize) {

        return ResponseEntity.ok(
                service.page(patientId, startTime, endTime, chamberNumber, operator, pageNum, pageSize)
        );
    }
}